From bf352dbea86bb7285c38b45e9305fdf3000e391e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 7 Aug 2014 08:27:05 -0700 Subject: [PATCH] Verbosely say what's happening during doc tests Or at least verbosely say when -v is provided. --- src/cargo/ops/cargo_test.rs | 13 +++++++++++-- tests/test_cargo_test.rs | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index 1609e0f62..695bd09c6 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -21,8 +21,14 @@ pub fn run_tests(manifest_path: &Path, Some(path) => path, None => exe.clone(), }; - try!(options.shell.status("Running", to_display.display())); - match compile.process(exe).args(args).exec() { + let cmd = compile.process(exe).args(args); + try!(options.shell.concise(|shell| { + shell.status("Running", to_display.display().to_string()) + })); + try!(options.shell.verbose(|shell| { + shell.status("Running", cmd.to_string()) + })); + match cmd.exec() { Ok(()) => {} Err(e) => return Ok(Some(e)) } @@ -58,6 +64,9 @@ pub fn run_tests(manifest_path: &Path, } } + try!(options.shell.verbose(|shell| { + shell.status("Running", p.to_string()) + })); match p.exec() { Ok(()) => {} Err(e) => return Ok(Some(e)), diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index f1a1c68c2..56e807194 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -46,6 +46,27 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n", RUNNING))); }) +test!(cargo_test_verbose { + let p = project("foo") + .file("Cargo.toml", basic_bin_manifest("foo").as_slice()) + .file("src/foo.rs", r#" + fn main() {} + #[test] fn test_hello() {} + "#); + + assert_that(p.cargo_process("cargo-test").arg("-v").arg("hello"), + execs().with_stdout(format!("\ +{running} `rustc src[..]foo.rs [..]` +{compiling} foo v0.5.0 ({url}) +{running} `[..]target[..]test[..]foo-[..] hello` + +running 1 test +test test_hello ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n", + compiling = COMPILING, url = p.url(), running = RUNNING))); +}) + test!(many_similar_names { let p = project("foo") .file("Cargo.toml", r#" -- 2.30.2